const Router=require('koa-router');
const classify=new Router(); 
const sqldata=require('../sqldata')
//查询主题
classify.get('/',async(ctx)=>{
    let val=ctx.request.query
    let sql=`select * from classify`
    let mydata = await new Promise((resolve, reject)=>{
        return sqldata(sql, (err, data)=>{
            if(err) reject(err);
            resolve(data);	// 返回拿到的数据
        })
    })
    ctx.body=mydata;
})
//各主题有关古诗
classify.get('/detail',async(ctx)=>{
    let val=ctx.request.query
    let sql=`select * from works,authorfoot where wtag like'%${val.clevel2} %' and works.aid=authorfoot.aid`
    let mydata = await new Promise((resolve, reject)=>{
        return sqldata(sql, (err, data)=>{
            if(err) reject(err);
            resolve(data);	// 返回拿到的数据
        })
    })
    ctx.body=mydata;
})
module.exports=classify;